package com.hdu.joinInMemory.service;

import org.apache.commons.collections.CollectionUtils;

import java.util.Collections;
import java.util.List;

/**
 * @description: 内存JoinService
 */

public interface JoinService {
    default <T> void joinInMemory(T t){
        if (t == null){
            return;
        }
        joinInMemory((Class<T>) t.getClass(), Collections.singletonList(t));
    }

    default <T> void joinInMemory(List<T> t){
        if (CollectionUtils.isEmpty(t)){
            return;
        }
        if (t.size() == 1){
            joinInMemory(t.get(0));
        }else {
            joinInMemory((Class<T>) t.get(0).getClass(), t);
        }
    }

    <T> void joinInMemory(Class<T> tCls, List<T> t);


    <T> void register(Class<T> tCls);
}
